from django.shortcuts import render

from testdemo import models
from  django.core.paginator import Paginator,EmptyPage,PageNotAnInteger,Page
import time

def time1(request):
    time1 = time.strftime('%Y-%m-%d', time.localtime(time.time()))
    ret = models.T_newsTables.objects.all().filter(post_date=time1)
    # paginator = Paginator(ret, 10)
    # current_page = request.GET.get('page')
    # current_page = int(current_page)
    # posts = paginator.page(current_page)
    # return render(request, 'time1.html', {'headline_list': posts,
    #                                       })
    return render(request, 'time1.html', {'headline_list': ret,
                                          })




def time2(request):
    time1 = time.strftime('%Y-%m-%d', time.localtime(time.time() - 86400))
    ret = models.T_newsTables.objects.all().filter(post_date=time1)
    # paginator = Paginator(ret, 10)
    # current_page = request.GET.get('page')
    # current_page = int(current_page)
    # posts = paginator.page(current_page)
    # return render(request, 'time1.html', {'headline_list': posts,
    #                                       })
    return render(request, 'time1.html', {'headline_list': ret,
                                          })


def time3(request):
    time1 = time.strftime('%Y-%m-%d', time.localtime(time.time() - 604800))
    ret = models.T_newsTables.objects.all().filter(post_date__gt=time1)
    # paginator = Paginator(ret, 10)
    # current_page = request.GET.get('page')
    # current_page = int(current_page)
    # posts = paginator.page(current_page)
    # return render(request, 'time1.html', {'headline_list': posts,
    #
    #                                       })
    return render(request, 'time1.html', {'headline_list': ret,

                                          })


def time4(request):
    time1 = time.strftime('%Y-%m-%d', time.localtime(time.time() - 2592000))
    ret = models.T_newsTables.objects.all().filter(post_date__gt=time1)
    # paginator = Paginator(ret, 10)
    #
    # current_page = request.GET.get('page')
    # current_page = int(current_page)
    # posts = paginator.page(current_page)
    #
    # return render(request, 'time1.html', {'headline_list': posts,
    #                                       })
    return render(request, 'time1.html', {'headline_list': ret,
                                          })
# Create your views here.
